#ifndef _Bullet_
#define _Bullet_
#include "stdafx.h"
#include "Math.h"
#include "CObject.h"
#include "Source.h"
#include "GameTime.h"
using namespace std;

class Bullet :public CObject
{
protected:
	ShootDirection shootDirection;

	Math m_Math;

	Auto m_Auto;

	float m_ConstSpeed;
	float speed;

	float m_TimeLive;
	float m_angle;

	float IncreaseX()
	{
		float a = (float)speed / sqrt(1 + tan(m_angle + getAngle()) * tan(getAngle() + m_angle));
		a += m_Position.x;
		return a;
	}
	float DecreaseX()
	{
		float a = (float)speed / sqrt(1 + tan(m_angle + getAngle()) * tan(getAngle() + m_angle));
		a = m_Position.x - a;
		return a;
	}

	float IncreaseY()
	{
		float a = (float)speed / sqrt(1 + tan(m_angle) * tan(m_angle));
		a += m_Position.y;
		return a;
	}

	float DecreaseY()
	{
		float a = (float)speed / sqrt(1 + tan(m_angle) * tan(m_angle));
		a = m_Position.y - a;
		return a;
	}
public:
	Bullet(IDImage gun, float timetolive);
	void setPosition(int x, int y, ShootDirection, Auto, float angle, float speed);
	float getAngle();
	void Draw(LPD3DXSPRITE SpriteHandle, float vpx);
	//void UpdateVeclocity();
	void Update();
	void setGun(IDImage gun);
	void InitTime();
	void UpdateCollision(){}
	bool isAlive();
	~Bullet();
};

#endif